package com.qifan.alb2b.action.back;

import java.util.HashMap;
import java.util.Map;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import com.qifan.alb2b.domain.ExchangeInfoDomain;
import com.qifan.alb2b.service.ExchangeInfoService;
import com.qifan.alb2b.util.DataGridModel;
import com.qifan.alb2b.util.ID;
import com.qifan.alb2b.util.Page;

@Controller
@RequestMapping("/admin/exchange")
public class ExchangeManageController{
	private ExchangeInfoService exchangeInfoService;

	public void setExchangeInfoService(ExchangeInfoService exchangeInfoService) {
		this.exchangeInfoService = exchangeInfoService;
	}
	
	@RequestMapping("/query.adm")
	@ResponseBody
	public Page query(DataGridModel dgm,ExchangeInfoDomain uqp) {
		//spring太给力了，可以自动装配两个对象  会自动的装返回的Map转换成JSON对象
		return exchangeInfoService.query(dgm,uqp);
	}
	
	@RequestMapping("/add.adm")
	@ResponseBody
	public Map<String, Object> add(ExchangeInfoDomain exchangeInfoDomain){
		Map<String, Object> map=new HashMap<String, Object>();
		exchangeInfoDomain.setExchangeId(ID.next()+"");//设置唯一ID
		exchangeInfoService.add(exchangeInfoDomain);
		map.put("success", true);
		return map;
	}
	
	@RequestMapping("/update")
	@ResponseBody
	public Map<String, Object> update(ExchangeInfoDomain exchangeInfoDomain){
		Map<String, Object> map=new HashMap<String, Object>();
		exchangeInfoService.update(exchangeInfoDomain);
		map.put("success", true);	
		return map;
	}
	
	@RequestMapping("/del.adm")
	@ResponseBody
	public Map<String, Object> delete(@RequestParam("uid") String[] ids){
		Map<String, Object> map=new HashMap<String, Object>();
		exchangeInfoService.delete(ids);
		map.put("success", true);
		return map;
	}
	
	
	
}
